<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <button id="button"></button>
    <!--<script>
        var _getElementById = document.getElementById;
        document.getElementById = function(){
            alert (1);
            return _getElementById.apply( document, arguments );
        }
        var button = document.getElementById( 'button' );
    </script>-->
</body>
<script>
    var _getElementById = document.getElementById;
    document.getElementById = function( id ){
        alert (1);
        return _getElementById( id ); // (1)
    }
    var button = document.getElementById( 'button' );
</script>
</html>